package test

import grails.test.*

class UserControllerTests extends ControllerUnitTestCase {
	void setUp() {
		super.setUp()
		String.metaClass.encodeAsMD5 = {
			org.codehaus.groovy.grails.plugins.codecs.MD5Codec.encode(delegate)
		}
	}

    protected void tearDown() {
        super.tearDown()
    }

    void testAddUserSuccess() {
		mockDomain(User)
		
		// given
		controller.params.login = "asdasd"
		controller.params.pass = "hahahihi"
		controller.params.email = "gaasfda@gmail.com"
		
		// when
		def result = controller.saveUser()
		
		println result
		// then
		assert result.createdUser.login == "asdasd"
		assert result.createdUser.password != "hahahihi"
		assert result.createdUser.email == "gaasfda@gmail.com"
    }
}
